<div id="main-form" class="save-details">
	<? if($message > 0){ ?>
		<div id="message_box">
			<p class="img"></p>
			<p class="txt">
				<? if($message == 1){
						echo "You have successfully added a new patient to your group.";
					}elseif($message == 2){
						echo "You have successfully updated patient details.";
					}
				?>
			</p>
		</div>

	<? }else{ ?>

		<form name="submitForm" id="submitForm" method="POST" action="<?=$_SERVER['REQUEST_URI']?>">
			<input type="hidden" name="id" value="<?=$patient_id;?>"/>
			<input type="hidden" name="patient_id" value="<?=$patient_id;?>"/>
			
			<div id="tabs">
				<ul>
					<li><a href="#tabs-1">Patient Details</a></li>
					<li><a href="#tabs-2">Personal Information</a></li>
					<li><a href="#tabs-3">Notes</a></li>
				</ul>
				<div id="tabs-1" class="patient-details">
					<ul class="singleColRows">
						<li class="leftcol" style="width:135px;">Health Center</li>
						<li class="rightcol">
							<?php
								if($_SESSION['account']['user_type_id'] == CONST_SUPER_ADMIN_TYPE){
									echo $group_select;
								}else{
									echo $_SESSION['account']['group_name'];
									echo "<input type='hidden' name='group_id' id='group_id' value='".$_SESSION['account']['group_id']."'>";
								}
							?>
						</li>
					</ul>
					<ul class="singleColRows">
						<li class="leftcol" style="width:135px;">Practicioner In Charge</li>
						<li class="rightcol"><?=$practicioner_select;?></li>
					</ul>
					<ul class="singleColRows">
						<li class="leftcol" style="width:135px;">Non-Practicioner In Charge</li>
						<li class="rightcol"><?=$non_practicioner_select;?></li>
					</ul>
					<ul class="singleColRows">
						<li class="leftcol" style="width:135px;">Status</li>
						<li class="rightcol">
							<input type="radio" name="active" value="0" <?=($patient_row['active'] == 0)?'checked':''?> > Inactive
							<input type="radio" name="active" value="1" <?=($patient_row['active'] == 1)?'checked':''?> > Active 
							<input type="radio" name="active" value="2" <?=($patient_row['active'] == 2)?'checked':''?> > Deceased
						</li>
					</ul>
				</div>

				<div id="tabs-2" class="patient-details">
					<ul class="main-two-cols">
						<li class="two-cols-left">
							<ul class="rows">
								<li class="leftcol">Title</li>
								<li class="rightcol">
									<input type="text" name="title" id="title" value="<?=$patient_row['title']?>">
								</li>
							</ul>
							<ul class="rows">
								<li class="leftcol">First Name</li>
								<li class="rightcol">
									<input type="text" name="fname" id="fname" value="<?=$patient_row['fname']?>">
								</li>
							</ul>
							<ul class="rows">
								<li class="leftcol">Middle Name</li>
								<li class="rightcol">
									<input type="text" name="mname" id="mname" value="<?=$patient_row['mname']?>">
								</li>
							</ul>
							<ul class="rows">
								<li class="leftcol">Surname</li>
								<li class="rightcol">
									<input type="text" name="lname" id="lname" value="<?=$patient_row['lname']?>">
								</li>
							</ul>
							<ul class="rows">
								<li class="leftcol">Nickname</li>
								<li class="rightcol">
									<input type="text" name="nickname" id="nickname" value="<?=$patient_row['nickname']?>">
								</li>
							</ul>
							<ul class="rows">
								<li class="leftcol">Date of Birth</li>
								<li class="rightcol">
									<input type="text" name="birthday" id="birthday" value="<?=$patient_row['birthday']?>">
								</li>
							</ul>
							<ul class="rows">
								<li class="leftcol">Gender</li>
								<li class="rightcol">
									<select name="gender" id="gender" style="width:76px">
										<option value=""></option>
										<option value="M" <?=($patient_row['gender'] == 'M') ? 'selected':''?> >Male</option>
										<option value="F" <?=($patient_row['gender'] == 'F') ? 'selected':''?> >Female</option>
									</select>&nbsp;&nbsp;
									Head of family
									<select name="head_of_family" id="head_of_family" style="width:55px">
										<option value=""></option>
										<option value="1" <?=($patient_row['head_of_family'] == 1) ? 'selected':''?> >Yes</option>
										<option value="0" <?=($patient_row['head_of_family'] == 0) ? 'selected':''?> >No</option>
									</select>
								</li>
							</ul>
							<ul class="rows">
								<li class="leftcol">ATSI</li>
								<li class="rightcol"><?=$atsi_select;?></li>
							</ul>
							<ul class="rows">
								<li class="leftcol">&nbsp;</li>
								<li class="rightcol">
									<input type="checkbox" name="ctg_registered" id="ctg_registered" value="1" <?=($patient_row['ctg_registered'] == 1) ? 'checked':'';?> >
									Registered for CTG Co-Payment Relief
								</li>
							</ul>
							<ul class="rows">
								<li class="leftcol">Address 1</li>
								<li class="rightcol">
									<textarea name="address1" id="address1"><?=$patient_row['address1']?></textarea>
								</li>
							</ul>
							<ul class="rows">
								<li class="leftcol">Address 2</li>
								<li class="rightcol">
									<textarea name="address2" id="address2"><?=$patient_row['address2']?></textarea>
								</li>
							</ul>
							<ul class="rows">
								<li class="leftcol">Address 3</li>
								<li class="rightcol">
									<textarea name="address3" id="address3"><?=$patient_row['address3']?></textarea>
								</li>
							</ul>
							<ul class="rows">
								<li class="leftcol">City/Suburb</li>
								<li class="rightcol">
									<input type="text" name="city" id="city" style="width:100px" value="<?=$patient_row['city']?>">&nbsp;&nbsp;
									Zipcode 
									<input type="text" name="zipcode" id="zipcode" style="width:50px" value="<?=$patient_row['zipcode']?>">
								</li>
							</ul>
							<ul class="rows">
								<li class="leftcol">&nbsp;</li>
								<li class="rightcol">
									<p>Select default phone number to be displayed</p>
									<input type="radio" name="default_phone_contact" value="home" <?=($patient_row['default_phone_contact'] == 'home') ? 'checked':'';?> > Home &nbsp;&nbsp;
									<input type="radio" name="default_phone_contact" value="work" <?=($patient_row['default_phone_contact'] == 'work') ? 'checked':'';?> > Work &nbsp;&nbsp;&nbsp;&nbsp;
									<input type="radio" name="default_phone_contact" value="mobile" <?=($patient_row['default_phone_contact'] == 'mobile') ? 'checked':'';?> > Mobile
								</li>
							</ul>
							<ul class="rows">
								<li class="leftcol">Phone</li>
								<li class="rightcol">
									<input type="text" name="phone_home" id="phone_home" style="width:64px" value="<?=$patient_row['phone_home']?>">
									<input type="text" name="phone_work" id="phone_work" style="width:64px" value="<?=$patient_row['phone_work']?>">
									<input type="text" name="phone_mobile" id="phone_mobile" style="width:64px" value="<?=$patient_row['phone_mobile']?>">
								</li>
							</ul>
							<ul class="rows">
								<li class="leftcol">Email</li>
								<li class="rightcol">
									<input type="text" name="email" id="email" value="<?=$patient_row['email']?>">
								</li>
							</ul>
						</li>

						<li class="two-cols-right">
							<ul class="rows">
								<li class="leftcol">Chart No.</li>
								<li class="rightcol">
									<input type="text" name="chart_no" id="chart_no" value="<?=$patient_row['chart_no']?>">
								</li>
							</ul>
							<ul class="rows">
								<li class="leftcol">Preferred Contact</li>
								<li class="rightcol">
									<select name="preferred_contact" id="preferred_contact">
										<option value=""></option>
										<option value="home" <?=($patient_row['preferred_contact'] == 'home') ? 'selected':'';?> >Home Landline</option>
										<option value="work" <?=($patient_row['preferred_contact'] == 'work') ? 'selected':'';?> >Work Landline</option>
										<option value="mobile" <?=($patient_row['preferred_contact'] == 'mobile') ? 'selected':'';?> >Mobile</option>
										<option value="email" <?=($patient_row['preferred_contact'] == 'email') ? 'selected':'';?> >Email</option>
									</select>
								</li>
							</ul>
							<ul class="rows">
								<li class="leftcol">Medicare No.</li>
								<li class="rightcol">
									<input type="text" name="medicare_no" id="medicare_no" value="<?=$patient_row['medicare_no']?>">
								</li>
							</ul>
							<ul class="rows">
								<li class="leftcol">Pension No.</li>
								<li class="rightcol">
									<input type="text" name="pension_no" id="pension_no" value="<?=$patient_row['pension_no']?>">
								</li>
							</ul>
							<ul class="rows">
								<li class="leftcol">DVA No.</li>
								<li class="rightcol">
									<input type="text" name="dva_no" id="dva_no" value="<?=$patient_row['dva_no']?>">
								</li>
							</ul>
							<ul class="rows">
								<li class="leftcol">Safety Net No.</li>
								<li class="rightcol">
									<input type="text" name="safety_net_no" id="safety_net_no" value="<?=$patient_row['safety_net_no']?>">
								</li>
							</ul>
							<ul class="rows">
								<li class="leftcol">Record No.</li>
								<li class="rightcol">
									<input type="text" name="record_no" id="record_no" value="<?=$patient_row['record_no']?>">
								</li>
							</ul>
							<ul class="rows">
								<li class="leftcol">IHI No.</li>
								<li class="rightcol">
									<input type="text" name="ihi_no" id="ihi_no" value="<?=$patient_row['ihi_no']?>">
								</li>
							</ul>
							<ul class="rows">
								<li class="leftcol">IHI Record Status</li>
								<li class="rightcol">
									<input type="text" name="ihi_record_status" id="ihi_record_status" value="<?=$patient_row['ihi_record_status']?>">
								</li>
							</ul>
							<ul class="rows">
								<li class="leftcol">Pension Status</li>
								<li class="rightcol">
									<input type="radio" name="pension_status" value="none" <?=($patient_row['pension_status'] == 'none') ? 'checked':'';?> > None <br/>
									<input type="radio" name="pension_status" value="pension/hcc" <?=($patient_row['pension_status'] == 'pension/hcc') ? 'checked':'';?> > Pension/HCC <br/>
									<input type="radio" name="pension_status" value="limited dva" <?=($patient_row['pension_status'] == 'limited dva') ? 'checked':'';?> > Limited DVA <br/>
									<input type="radio" name="pension_status" value="full dva" <?=($patient_row['pension_status'] == 'full dva') ? 'checked':'';?> > Full DVA <br/>
								</li>
							</ul>
							<ul class="rows">
								<li class="leftcol">&nbsp;</li>
								<li class="rightcol">
									<input type="checkbox" name="withdrawn_consent" id="withdrawn_consent" value="1" <?=($patient_row['withdrawn_consent'] == 1) ? 'checked':'';?> >
									This patient has withdrawn consent to upload clinical documents to PCEHR
								</li>
							</ul>
							<ul class="rows">
								<li class="leftcol">ePrescribing</li>
								<li class="rightcol">
									<input type="radio" name="eprescribing" value="always receive" <?=($patient_row['eprescribing'] == "always receive") ? 'checked':'';?> > Always receive dispense notification <br/>
									<input type="radio" name="eprescribing" value="ask consent" <?=($patient_row['eprescribing'] == "ask consent") ? 'checked':'';?> > Ask for consent on every prescription <br/>
									<input type="radio" name="eprescribing" value="never receive" <?=($patient_row['eprescribing'] == "never receive") ? 'checked':'';?> > Never receive dispense notification <br/>
									<input type="radio" name="eprescribing" value="disable" <?=($patient_row['eprescribing'] == "disable") ? 'checked':'';?> > Disable ePrescribing <br/>
								</li>
							</ul>
						</li>
					</ul>
				</div>

				<!-- Notes tab -->
				<div id="tabs-3" class="patient-notes">
					<ul class="main-two-cols">
						<li class="two-cols-left">
							<ul class="rows">
								<li class="leftcol">Notes</li>
								<li class="rightcol">
									<textarea name="notes" id="notes" style="height:205px"><?=$patient_row['notes']?></textarea>
								</li>
							</ul>
						</li>
						<li class="two-cols-right">
							<ul class="rows">
								<li class="leftcol">Referral</li>
								<li class="rightcol">&nbsp;</li>
							</ul>
							<ul class="rows">
								<li class="leftcol">Referring Doctor</li>
								<li class="rightcol">
									<input type="text" name="referring_doctor" id="referring_doctor" value="<?=$patient_row['referring_doctor']?>">
								</li>
							</ul>
							<ul class="rows">
								<li class="leftcol">Referral Date</li>
								<li class="rightcol">
									<input type="text" name="referral_date" id="referral_date" value="<?=$patient_row['referral_date']?>">
								</li>
							</ul>
							<ul class="rows">
								<li class="leftcol">Health Fund Name</li>
								<li class="rightcol"><?=$health_fund_select;?></li>
							</ul>
							<ul class="rows">
								<li class="leftcol">Health Fund No.</li>
								<li class="rightcol">
									<input type="text" name="health_fund_no" id="health_fund_no" value="<?=$patient_row['health_fund_no']?>">
								</li>
							</ul>
							<ul class="rows">
								<li class="leftcol">Health Fund Type</li>
								<li class="rightcol"><?=$health_fund_type_select;?></li>
							</ul>
						</li>
					</ul>
				</div>
				<br clear="all" />
			</div>

			<p class="buttons_elements">
				<input type="submit" class="form-button btn" id="submitBtn" value="Save">
				<input type="button" class="form-button btn" id="cancelBtn" value="Cancel" >
			</p>
			<br clear="all" />
		</form>

	<? } ?>
</div>

<script type="text/javascript">
	$( document ).ready(function() {
		$("#birthday").datepicker();
		$("#referral_date").datepicker();
		$('#practicioner').multiSelect();
		$('#non_practicioner').multiSelect();
	});
</script>